Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nuxt baseURL support #76

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

nuxt baseURL support #76

wants to merge 4 commits into from

Conversation

Flows-git
Copy link

I saw in the issue #60 that the support for nuxt baseURL is planned but not done yet. But we needed it asap for our project. So I decided to fix it. We published this to our company nexus but you can take it if you want.

I realized useRequestFetch, navigateTo , sendRedirect and the callbackRedirectUrl didn't work with correctly with a baseURL set. So I created a function which adds the baseURL to a passed url and added it to the named functions.

You can find the function to parse the URL here.
It tried to store the function in config but that doesn't work and the other files doesn't seem to fit. So I decided to create a new file. Maybe you have a better idea where to store it.

Test
Add NUXT_APP_BASE_URL=/app/ to .env or app: { baseURL: '/app/' } to nuxt.config and start the playground.

I tested it with the keycloak provider only. But it doesn't changes anything with the providers so (I think) there should be no Problem with other providers.

@itpropro
Copy link
Owner

itpropro commented Jan 6, 2025

I was actually not able to reproduce the problem. I set a different baseURL in the nuxt config and all redirections from the composable and from the server continued to work based on how nuxt handles the redirections internally.
Can you provide a reproduction where this problem occurs?

@lucky-tut
Copy link

lucky-tut commented Mar 28, 2025

Hello,
unfortunately, I have the same issue with baseURL. The problem is that there are two applications: one is hosted on NUXT_PUBLIC_SITE_URL (mysite.com) and the other one on NUXT_PUBLIC_SITE_URL/BASE_URL (mysite.com/v2)

The redirection from the composable is not possible, the provider simply calls mysite.com/auth/login which is completely different web app. I could make it through the ugly hack, instead of login() used /v2/auth/login.

However, I have another issue with callbackRedirectUrl.

nuxt.config.ts
//...
 providers: {
      keycloak: {
         //...
         callbackRedirectUrl: '/v2/home'
        //..
}

The callback redirection is working fine on dev mode, but on prod mode the calback redirect url is always /. For publishing IIS setup is used.
I hope that at least the first issue could be solved by proposed changes in the PR, however not quite sure about the last one with callbackRedirectUrl.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants